Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove redundant async in readable.js #3643

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Sep 25, 2024

fixes #3610

We dont need to wrap non awaited Promises/async calls.

@Uzlopak Uzlopak requested a review from mcollina September 25, 2024 17:19
@mcollina mcollina requested a review from KhafraDev September 26, 2024 08:07
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this improving anything? This will worsen the DX as .json() will disappear from the stacktrace.

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 26, 2024

Let me check the stack traces.

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 26, 2024

@mcollina

'use strict'

const { Client } = require('./index')

async function run() {
    const client = new Client('https://www.google.com')
    const { body } = await client.request({
      path: '/',
      method: 'GET'
    })
    console.log(await body.json())
    client.destroy()
}

run()

In both branches I get:

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at consumeEnd (/home/aras/undici/lib/api/readable.js:505:20)
    at BodyReadable.<anonymous> (/home/aras/undici/lib/api/readable.js:429:7)
    at BodyReadable.emit (node:events:517:28)
    at endReadableNT (node:internal/streams/readable:1400:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 30, 2024

@mcollina

Can I merge?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit a363a2d into main Oct 15, 2024
38 checks passed
@mcollina mcollina deleted the remove-redundant-async branch October 15, 2024 17:00
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
This was referenced Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unnecessary async?
3 participants